package com.itheima.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Slf4j
//@Aspect
//@Component
public class DemoAspect {
    @Around("execution(* com.itheima.service.Impl.DeptServiceImpl.*(..))")
    public Object recordTime(ProceedingJoinPoint joinPoint) throws Throwable {
        //开始时间
        long begin = System.currentTimeMillis();

        //2.运行原始方法
        Object result=joinPoint.proceed();

        //结束时间
        long end=System.currentTimeMillis();
        //打印
        log.info("方法执行时间为：{}ms",end-begin);
        return result;
    }
}
